package com.t3.fx
{
	import flash.display.Shape;

	public class DragState extends Shape
	{
		private var _dob:DraggableObject;
		private var _width:Number;
		private var _height:Number;
		private var _prevArea:DropArea;
		private var _prevState:Boolean = false;
		private var _dropArea:DropArea;
		
		private var _xOrigin:Number;
		private var _yOrigin:Number;
		private var _dropOrigin:DropArea;
		
		public function DragState( dob:DraggableObject ):void
		{
			super();
			
			_dob = dob;
			_width = dob.width;
			_height = dob.height;
			_xOrigin = dob.x;
			_yOrigin = dob.y;
			
			this.repaint( 0xFF0000 );
		}
		
		public function set dropAllowed( dropAllowed:Boolean ):void
		{
			if( dropAllowed && !_prevState )
			{
				repaint( 0x00FF00 );
			}
			else if( !dropAllowed && _prevState )
			{
				repaint( 0xFF0000 );
			}
			
			_prevState = dropAllowed;
		}
		
		public function repaint( color:Number ):void
		{
			this.graphics.clear();
			this.graphics.lineStyle( 3, color );
			this.graphics.drawCircle( _width/2, _height/2, _width/2+20 );
		}
		
		public function get dropAllowed():Boolean
		{
			return _prevState;
		}
		
		public function set dropArea( da:DropArea ):void
		{ 
			_dropArea = da;
		}
		
		public function get dropArea():DropArea
		{
			return _dropArea;
		}
		
		public function set xOrigin( xo:Number ):void
		{
			_xOrigin = xo;
		}
		
		public function get xOrigin():Number
		{
			return _xOrigin;
		}
		
		public function set yOrigin( yo:Number ):void
		{
			_yOrigin = yo;
		}
		
		public function get yOrigin():Number
		{
			return _yOrigin;
		}
		
		public function set dropOrigin( da:DropArea ):void
		{
			_dropOrigin = da;
		}
		
		public function get dropOrigin():DropArea
		{
			return _dropOrigin;
		}
	}
}